package com.sttk.fastMark.camera.utils;

import com.blankj.utilcode.util.GsonUtils;
import com.blankj.utilcode.util.SPUtils;
import com.google.gson.reflect.TypeToken;
import com.sttk.fastMark.camera.bean.ConstructionLogBean;
import com.sttk.fastMark.camera.bean.MeetingSummaryBean;
import com.sttk.fastMark.camera.bean.PersonalCardBean;
import com.sttk.fastMark.camera.bean.ResolutionBean;
import com.sttk.fastMark.camera.bean.WatermarkBean;
import com.sttk.fastMark.camera.bean.WorkReportBean;

import java.util.List;


public class AppSpUtils {
    private static final String SP_NAME = "appCollSp";
    private static final SPUtils sSpUtils = SPUtils.getInstance(SP_NAME);



    public static void saveResolution(ResolutionBean bean) {
        String json = GsonUtils.toJson(bean);
        sSpUtils.put(Key.key_resolution, json);
    }

    public static ResolutionBean getResolution() {
        String json = sSpUtils.getString(Key.key_resolution);
        return GsonUtils.fromJson(json, new TypeToken<ResolutionBean>() {
        }.getType());
    }

    public static void saveWatermarkList(List<WatermarkBean> list) {
        String json = GsonUtils.toJson(list);
        sSpUtils.put(Key.key_watermark_list, json);
    }

    public static List<WatermarkBean> getWatermarkList() {
        String json = sSpUtils.getString(Key.key_watermark_list);
        return GsonUtils.fromJson(json, new TypeToken<List<WatermarkBean>>() {
        }.getType());
    }

    public static void savePersonalCard(PersonalCardBean bean) {
        String json = GsonUtils.toJson(bean);
        sSpUtils.put(Key.key_personal_card, json);
    }

    public static PersonalCardBean getPersonalCard() {
        String json = sSpUtils.getString(Key.key_personal_card);
        return GsonUtils.fromJson(json, new TypeToken<PersonalCardBean>() {
        }.getType());
    }

    public static void saveWorkReport(WorkReportBean bean) {
        String json = GsonUtils.toJson(bean);
        sSpUtils.put(Key.key_work_report, json);
    }

    public static WorkReportBean getWorkReport() {
        String json = sSpUtils.getString(Key.key_work_report);
        return GsonUtils.fromJson(json, new TypeToken<WorkReportBean>() {
        }.getType());
    }

    public static void saveConstructionLog(ConstructionLogBean bean) {
        String json = GsonUtils.toJson(bean);
        sSpUtils.put(Key.key_construction_log, json);
    }

    public static ConstructionLogBean getConstructionLog() {
        String json = sSpUtils.getString(Key.key_construction_log);
        return GsonUtils.fromJson(json, new TypeToken<ConstructionLogBean>() {
        }.getType());
    }

    public static void saveMeetingSummary(MeetingSummaryBean bean) {
        String json = GsonUtils.toJson(bean);
        sSpUtils.put(Key.key_meeting_summary, json);
    }

    public static MeetingSummaryBean getMeetingSummary() {
        String json = sSpUtils.getString(Key.key_meeting_summary);
        return GsonUtils.fromJson(json, new TypeToken<MeetingSummaryBean>() {
        }.getType());
    }

    interface Key {
        String key_resolution = "key_resolution";
        String key_watermark_list = "key_watermark_list";
        String key_personal_card = "key_personal_card";
        String key_work_report = "key_work_report";
        String key_construction_log = "key_construction_log";
        String key_meeting_summary = "key_meeting_summary";
    }
}